package com.study8.demo8.aspecj;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;

@Aspect
@Component
public class MyAspect {

  @Pointcut("@annotation(com.study8.demo8.aopInterface.MyInterface)")
  public void annotationPoinCut(){}

  @Before("execution(* com.study8.demo8.service.*.*(..))")
  public void before(JoinPoint joinPoint){
    MethodSignature signature = (MethodSignature) joinPoint.getSignature();
    Method method = signature.getMethod();
    System.out.println("方法规则式拦截,"+method.getName());
  }
}